
#include "contract.h"
#include "BSP_IO.h"


static rcu_periph_enum gpio_clock(GP_T gp){
	switch(gp){
	case GPIOA:	return RCU_GPIOA;
	case GPIOB:	return RCU_GPIOB;
	case GPIOC:	return RCU_GPIOC;
	case GPIOD:	return RCU_GPIOD;
	case GPIOE:	return RCU_GPIOE;
	case GPIOF:	return RCU_GPIOF;
	case GPIOG:	return RCU_GPIOG;
	}
	ASSERT(0);
	return (rcu_periph_enum)0;
}

void BSP_IO_Init(GP_T gp, Pin_T pin, uint32_t mode){	
	rcu_periph_clock_enable(gpio_clock(gp));
	gpio_init(gp, mode, GPIO_OSPEED_50MHZ, pin);
}

void BSP_IO_SetMode(GP_T gp, Pin_T pin, uint32_t mode){
	gpio_init(gp, mode, GPIO_OSPEED_50MHZ, pin);
}

#if 0
void BSP_IO_EnableInt(GP_T gp, Pin_T pin, uint32_t attribs){
	GPIO_EnableInt(gpioPorts[gp], pin, attribs);
}

void BSP_IO_DisableInt(GP_T gp, Pin_T pin){
	GPIO_DisableInt(gpioPorts[gp], pin);
}
#endif 

